﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.NetworkInformation;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Navigation;

namespace TwitterBEIS_SL3_SLApp
{
    public partial class MainPage : UserControl
    {
        public MainPage()
        {
            InitializeComponent();
            SetBtns(false);
        }

        private void NavButton_Click(object sender, RoutedEventArgs e)
        {
            Button navigationButton = sender as Button;
            String goToPage = navigationButton.Tag.ToString();
            this.Frame.Navigate(new Uri(goToPage, UriKind.Relative));
        }

        public void EnableBtns()
        {
            SetBtns(true);
        }

        public void DisableBtns()
        {
            SetBtns(false);
        }

        private void SetBtns(bool b)
        {
            HomeBtn.IsEnabled = b;
            RepliesBtn.IsEnabled = b;
            DMsBtn.IsEnabled = b;
            SentBtn.IsEnabled = b;
            FriendsBtn.IsEnabled = b;
        }

        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            if (!NetworkInterface.GetIsNetworkAvailable())
            {
                if (Storage.ReadSecret())
                {
                    Frame.Source = new Uri("/Views/Home.xaml", UriKind.Relative);
                }
            }
        }
    }
}
